//商家店铺列表
<template>
   <div class="search">
    <Row>
      <Col>
        <Card>
          <Row class="operation">
          <Row>
            <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort"></Table>
          </Row>
          <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
          </Row>
          </Row>
        </Card>
      </Col>
    </Row>
    </div> 
</template>

<script>
export default {
  data(){
    return{
      submitLoading: false, // 添加或编辑提交状态
      modalVisible:false,
      loading:true,
      total:0,
      data:[],//表单数据
      searchForm:{
        pageNumber:1,
        pageSize:10,
      },
      columns: [
        // 表头
        {
          type: "index",
          width: 60,
          align: "center"
        },
        {
          title: "头像",
          key: "avatar",
          minWidth: 120,
          sortable: false,
          render: (h, params) => {
            return h("avatar", {
              props: {
                src: params.row.avatar
              }
            });
          }
        },
        {
          title: "姓名",
          key: "username",
          minWidth: 120,
          sortable: false,
        },
        {
          title: "商家类型",
          key: "storeType",
          minWidth: 120,
          sortable: false,
          render: (h,params) => {
            if (params.row.storeType === 2) {
              return h("span", "个人商家")
            } else if (params.row.storeType === 3) {
              return h("span", "商家")
            }
          }
        },
        {
          title: "最低价格（元）",
          key: "lowPrice",
          minWidth: 120,
          sortable: false,
        },
        {
          title: "创建时间",
          key: "createTime",
          minWidth: 120,
          sortable: false,
        }
      ],
    }
  },
  methods:{
    init(){
      this.getDataList()
    },
    //获取商家列表
    getDataList(){
      this.loading = true;
      this.postRequest("/selectStore/getSelectStoreList",this.searchForm).then(res =>{
        this.loading = false;
        if(res.success){
          var arr = res.result.data;
          for(let val of arr){
            for(let i in val){
              (val[i] === null) ? (val[i] = "-") : ""
            }
          }
          this.data = res.result.data;
          this.total = res.result.size;
        } else {
          this.data = [];
          this.total = 0;
        }
      })
    },
    changeSort(e) {
      this.searchForm.sort = e.key;
      this.searchForm.order = e.order;
      if (e.order === "normal") {
        this.searchForm.order = "";
      }
      this.getDataList();
    },
    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getDataList();
    },
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getDataList();
    },
    },
    mounted(){
      this.init()
    }
}
</script>

<style lang="less" scoped>
.search {
    .operation {
        margin-bottom: 2vh;
    }
    .select-count {
        font-size: 13px;
        font-weight: 600;  
        color: #40a9ff;
    }
    .select-clear {
        margin-left: 10px;
    }
    .page {
        margin-top: 2vh;
    }
    .drop-down {
        font-size: 13px;
        margin-left: 5px;
    }
}
</style>